﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;

namespace employee.Controls
{
    public partial class emRelativeDetail : common.controls.baseUserControl
    {
        public emRelativeDetail()
        {
            InitializeComponent();
        }

        protected void SetDataSource(BindingSource dataSrc)
        {
            common.BindingLibs.BindObject(this.relativeCodeEd, dataSrc, DataAccess.DataCache.myBaseDS.emRelatives.relativeCodeColumn.ColumnName);
            common.BindingLibs.BindObject(this.familyRelaTypeCb, dataSrc, DataAccess.DataCache.myBaseDS.emRelatives.relationTypeColumn.ColumnName);
            common.BindingLibs.BindObject(this.fulllNameEd, dataSrc, DataAccess.DataCache.myBaseDS.emRelatives.fullNameColumn.ColumnName);
            common.BindingLibs.BindObject(this.addressEd, dataSrc, DataAccess.DataCache.myBaseDS.emRelatives.addressColumn.ColumnName);

            fulllNameEd.MaxLength = DataAccess.DataCache.myBaseDS.emRelatives.fullNameColumn.MaxLength;
            addressEd.MaxLength = DataAccess.DataCache.myBaseDS.emRelatives.addressColumn.MaxLength;
        }

        public virtual void Init(BindingSource dataSrc) 
        {
            familyRelaTypeCb.LoadData();
            SetDataSource(dataSrc);
        }

        public virtual bool CheckData()
        {
            bool retVal = true;
            ClearNotifyError();
            //if (fulllNameEd.Text.Trim() == "") 
            //{
            //    NotifyError(fulllNameLbl);
            //    retVal = false;
            //}
            //if (familyRelaTypeCb.myValue == "")
            //{
            //    NotifyError(relativeTypeLbl);
            //    retVal = false;
            //}
            return retVal;
        }
        public virtual void LockEdit(bool state)
        {
            state = !state;
            relativeCodeEd.Enabled = state;
            fulllNameEd.Enabled = state;
            familyRelaTypeCb.Enabled = state;
            addressEd.Enabled = state;
        }
        public virtual void SetFocus()
        {
            this.Focus();
            familyRelaTypeCb.Focus();
        }
    }
}
